package org.jbrisk;

public interface IServiceContainer {

	/**
	 * Indicates if the service from the supplied class exists.
	 * 
	 * @param svcClass
	 *            Class used to uniquely identify the service.
	 * @return True or false.
	 */
	public boolean hasService(Class<?> svcClass);

	/**
	 * Removes the supplied service.
	 * 
	 * @param svcClass
	 *            Class used to uniquely identify the service.
	 */
	public <T> void removeService(Class<T> svcClass);

	/**
	 * Adds a service to this workspace.
	 * 
	 * @param svcClass
	 *            Class used to uniquely identify the service.
	 * @param svc
	 *            Service instance.
	 */
	public <T> void addService(Class<T> svcClass, T svc);
	
	/**
	 * Adds a service to this workspace.
	 * 
	 * @param svcClass
	 *            Class used to uniquely identify the service.
	 * @param svc
	 *            Service instance.
	 * @param replaceExisting
	 *            Indicates if it should replace the existing service or throw
	 *            an error if there is one already. Default is <code>true</code>
	 */
	public <T> void addService(Class<T> svcClass, T svc, boolean replaceExisting);

	/**
	 * Returns the currently registered service instance from the supplied
	 * Class.
	 * 
	 * @param <T>
	 *            Service class.
	 * @param svcClazz
	 *            Service class.
	 * @return Service instance.
	 */
	public <T> T getService(Class<T> svcClazz);

	/**
	 * Returns the currently registered service instance from the supplied
	 * Class.
	 * 
	 * @param <T>
	 *            Service class.
	 * @param svcClazz
	 *            Service class.
	 * 
	 * @param throwErrorIfNotFound
	 *            Indicates if it should throw an error if the service cannot be
	 *            found.
	 * @return Service instance.
	 */
	public <T> T getService(Class<T> svcClazz, boolean throwErrorIfNotFound);
}
